import request from "@/utils/request";

/**
 * 识别记录列表
 * @param pages
 */
export function getFaceRecordList(pages: any) {
  let url = "api/v1/sysuser/personFaceScanRecord/personFaceScanRecord_page";
  switch (localStorage.getItem("usertypeName")) {
    case "Corp":
      url = "api/v1/corp/personFaceScanRecord/personFaceScanRecord_page";
      break;
    case "Manager":
      url = "api/v1/manager/personFaceScanRecord/personFaceScanRecord_page";
      break;
  }
  return request({
    url: url,
    method: "get",
    params: pages,
  });
}

/**
 * 根据ID获取识别照片(App认证记录)
 * @param pages
 */
export function getFaceRecordImageById(id: any) {
  let url = "api/v1/sysuser/personFaceScanRecord/getImage/" + id;
  switch (localStorage.getItem("usertypeName")) {
    case "Corp":
      url = "api/v1/corp/personFaceScanRecord/getImage/" + id;
      break;
    case "Manager":
      url = "api/v1/manager/personFaceScanRecord/getImage/" + id;
      break;
  }
  return request({
    url: url,
    method: "get",
  });
}

/**
 * 根据身份证号获取身份证照片
 * @param pages
 */
export function getImageByIdCard(idCard: string) {
  let url = "api/v1/sysuser/personFaceScanRecord/getImageByIdCard/" + idCard;
  switch (localStorage.getItem("usertypeName")) {
    case "Corp":
      url = "api/v1/corp/personFaceScanRecord/getImageByIdCard/" + idCard;
      break;
    case "Manager":
      url = "api/v1/manager/personFaceScanRecord/getImageByIdCard/" + idCard;
      break;
  }
  return request({
    url: url,
    method: "get",
  });
}

/**
 * 根据身份证号获取核验照片
 * @param pages
 */
export function getImageByIdCardVerify(idCard: string) {
  let url = "api/v1/sysuser/personFaceScanRecord/getImageByIdCardVerify/" + idCard;
  switch (localStorage.getItem("usertypeName")) {
    case "Corp":
      url = "api/v1/corp/personFaceScanRecord/getImageByIdCardVerify/" + idCard;
      break;
    case "Manager":
      url = "api/v1/manager/personFaceScanRecord/getImageByIdCardVerify/" + idCard;
      break;
  }
  return request({
    url: url,
    method: "get",
  });
}

/**
 * 根据ID获取识别照片(考勤)
 * @param pages
 */
export function getImage_checkindetail(id: string, month: string) {
  return request({
    url: `api/v1/common/getImage/${id}/${month}`,
    method: "get",
  });
}

export function updatePersonFacePhoto(personFaceScanRecordId: number, idCard: string) {
  let url = "api/v1/sysuser/personFaceScanRecord/updatePersonFacePhoto";
  switch (localStorage.getItem("usertypeName")) {
    case "Corp":
      url = "api/v1/corp/personFaceScanRecord/updatePersonFacePhoto";
      break;
    case "Manager":
      url = "api/v1/manager/personFaceScanRecord/updatePersonFacePhoto";
      break;
  }
  return request({
    url: url,
    method: "put",
    data: { personFaceScanRecordId: personFaceScanRecordId, idCard: idCard },
  });
}
